WOLF core
WOLF: A Modular Estimation Framework for Robotics
XXXXXXXXXXXXXXXXXXXXXXXXvoid(0)" frameborder="0" name="MSearchResults" id="MSearchResults">
state_angle.h
Go to the documentation of this file.
1// WOLF - Copyright (C) 2020-2026
2// Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
3// Authors: Joan Solà Ortega (jsola@iri.upc.edu) and
4// Joan Vallvé Navarro (jvallve@iri.upc.edu)
5// All rights reserved.
6//
7// This file is part of WOLF: http://www.iri.upc.edu/wolf
8// WOLF is free software: you can redistribute it and/or modify
9// it under the terms of the GNU General Public License version 3
10// as published by the Free Software Foundation.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19#pragma once
20
23
24namespace wolf
25{
26class StateAngle : public StateBlock
27{
28 public:
29 StateAngle(double _angle, bool _fixed = false, bool _transformable = true);
30 StateAngle(const Eigen::VectorXd& _angle, bool _fixed = false, bool _transformable = true);
31
32 static Eigen::VectorXd Identity();
33
35
36 ~StateAngle() override;
37
38 virtual void transform(const VectorComposite& _transformation) override;
39};
40
41inline StateAngle::StateAngle(double _angle, bool _fixed, bool _transformable)
42 : StateBlock("StateAngle", 1, _fixed, std::make_shared<LocalParametrizationAngle>(), _transformable)
43{
44 state_(0) = pi2pi(_angle);
45}
46
47inline StateAngle::StateAngle(const Eigen::VectorXd& _angle, bool _fixed, bool _transformable)
48 : StateBlock("StateAngle", 1, _fixed, std::make_shared<LocalParametrizationAngle>(), _transformable)
49{
50 if (_angle.size() != 1) throw std::runtime_error("The angle state vector must be of size 1!");
51
52 state_(0) = pi2pi(_angle(0));
53}
54
55inline Eigen::VectorXd StateAngle::Identity()
56{
57 return Eigen::VectorXd::Zero(1);
58}
59
61{
62 //
63}
64
65inline void StateAngle::transform(const VectorComposite& _transformation)
66{
67 if (isTransformable()) setState(_transformation.at('O') + getState()); // 2D rotation is a sum of angles
68}
69
70} /* namespace wolf */
Definition: local_parametrization_angle.h:27
Definition: state_angle.h:27
~StateAngle() override
Definition: state_angle.h:60
static Eigen::VectorXd Identity()
Definition: state_angle.h:55
StateAngle(double _angle, bool _fixed=false, bool _transformable=true)
Definition: state_angle.h:41
WOLF_STATE_BLOCK_CREATE(StateAngle)
virtual void transform(const VectorComposite &_transformation) override
Definition: state_angle.h:65
class StateBlock
Definition: state_block.h:73
bool isTransformable() const
Definition: state_block.h:219
void setState(const Eigen::VectorXd &_state, const bool _notify=true)
Sets the state vector.
Definition: state_block.cpp:25
Eigen::VectorXd getState() const
Returns the state vector.
Definition: state_block.h:296
Eigen::VectorXd state_
State vector storing the state values.
Definition: state_block.h:80
Definition: vector_composite.h:27
Definition: jet.h:1355
Definition: capture_base.h:23
T pi2pi(const T &_angle)
Return angle between -pi and pi This implementation uses std::remainder which makes it incompatible f...
Definition: rotations.h:34